﻿// Copyright (c) 2014 Converter Systems LLC

using ConverterSystems.Windows.Data;
using System;
using System.Globalization;
using System.Windows.Data;

namespace ConverterSystems.Workstation.Data
{
    [ValueConversion(typeof(DateTime), typeof(String))]
    public class UtcToLocalStringConverter : ValueConverter<DateTime, String>
    {
        protected override String Convert(DateTime value, object parameter, CultureInfo culture)
        {
            var s = parameter as string;
            if (s != null)
            {
                return value.ToLocalTime().ToString(s, culture);
            }
            return value.ToLocalTime().ToString(culture);
        }
    }
}